/**
 * 
 */
function sim_initial(){
	setvalue_plug();
	setvalue_type();
	setvalue_min();
	setvalue_max();
	setvalue_date();
	setvalue_smax();
}
function setvalue_plug(){
	var plugvalue = document.getElementById("plugid").options[document.getElementById("plugid").options.selectedIndex].value;
	window.self.document.all.sim_plug_id.value = plugvalue;
}
function setvalue_type(){
	var typevalue = document.getElementById("typeid").options[document.getElementById("typeid").options.selectedIndex].value;
	document.all.sim_type_id.value = typevalue;
	data_type_changed(typevalue);
}
function setvalue_min(){
	document.all.sim_min.value = document.all.input_min.value;
}
function setvalue_max(){
	document.all.sim_max.value = document.all.input_max.value;
}
function setvalue_date(){
	document.all.sim_date.value = document.all.input_date.value;
}
function setvalue_smax(){
	document.all.sim_smax.value = document.all.input_smax.value;
}
function sim_submit(){
	sim_initial();
	var sim_form = document.getElementById("sim_form");
	sim_form.submit();
}
function data_type_changed(typevalue){
	if(typevalue == "2"){
		document.getElementById("param_slope_random").style.display = "block";
	} else {
		document.getElementById("param_slope_random").style.display = "none";
	}
}
function to_date(sDate){
	document.all.date.value = sDate;
	var df = document.getElementById("dateForm");
	df.submit();
}

function loadXmlFile(xmlFile){
	var xmlDom = null;
	if (window.ActiveXObject){
		xmlDom = new ActiveXObject("Microsoft.XMLDOM");
		//xmlDom.loadXML(xmlFile);//如果用的是XML字符串
		xmlDom.load(xmlFile);//如果用的是xml文件。
	} else if(document.implementation && document.implementation.createDocument){
		var xmlhttp = new window.XMLHttpRequest();
		xmlhttp.open("GET", xmlFile, false);
		xmlhttp.send(null);
		xmlDom = xmlhttp.responseXML;
	} else {
		xmlDom = null;
	}
	return xmlDom;
}

function getOs(){
	var sObject = "";
	if(navigator.userAgent.indexOf("MSIE")>0) {
		return "MSIE";
	}
	if(isFirefox=navigator.userAgent.indexOf("Firefox")>0){
		return "Firefox";
	}
	if(isSafari=navigator.userAgent.indexOf("Safari")>0) {
		return "Safari";
	}
	if(isCamino=navigator.userAgent.indexOf("Camino")>0){
		return "Camino";
	}
	if(isMozilla=navigator.userAgent.indexOf("Gecko/")>0){
		return "Gecko";
	}
}

function show_plug_data(pid){
	var Url = "dbcon?action=xml&xml_content=plug&pid=" + pid;
	//var Url = "aaa.xml";
	var xmlDom = loadXmlFile(Url);
	var lth = xmlDom.getElementsByTagName("plug-pcd")[0].getAttribute('length');
	
	for(var i=0; i<lth && i<chartData.length; i++){
		chartData[i]["pvalue"] = xmlDom.getElementsByTagName("plug")[i].getAttribute("power");
	}
	
	//window.alert("value:"+chartData[1]["value"] + "\npvalue:"+chartData[1]["pvalue"]);
	refreshChart();
}

function getGraphTypeSelection(){
	if(document.getElementById("rb1").checked){
		return "line";
	}
	if(document.getElementById("rb2").checked){
		return "smoothedLine";
	}
	if(document.getElementById("rb3").checked){
		return "step";
	}
}

function refreshChart(){
	if(!pluggraph){
		pluggraph = new AmCharts.AmGraph();
		pluggraph.lineColor = "#01A4FB";
		pluggraph.fillColors = "#01A4FB";
		pluggraph.negativeLineColor = "#009900";
		pluggraph.negativeFillColors = "#009900";
		pluggraph.fillAlphas = 0.3;
		pluggraph.valueField = "pvalue";
		pluggraph.type = getGraphTypeSelection();
		chart.addGraph(pluggraph);
	} else {
		
	}
	chart.validateNow();
}









